﻿<Window x:Class="ResourceBlender.Express.WinBulkAddElements"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:loc="clr-namespace:ResourceBlender.Express"
    xmlns:props="clr-namespace:ResourceBlender.Express.Properties"
    Title="Bulk Add Elements" WindowStartupLocation="CenterOwner"
    MinHeight="200" Height="400" MinWidth="250" Width="400"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlenderExpress;component/Resources/images/resourceblender.ico">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <CommandBinding Command="ApplicationCommands.Help" Executed="ShowHelp" />
        <CommandBinding Command="ApplicationCommands.New" Executed="AddElement" CanExecute="CanAlwaysExecute" />
        <CommandBinding Command="ApplicationCommands.Save" Executed="Save" />
        <CommandBinding Command="loc:ResourceBlenderCommands.Delete" Executed="DeleteElement" />
    </Window.CommandBindings>
    <DockPanel LastChildFill="True">
        <ToolBar DockPanel.Dock="Top">
            <loc:ImageButton Command="ApplicationCommands.New" Text="Add" Image="Resources/images/add_16.png" ShowText="False" ToolTip="Add Element" Style="{StaticResource ToolBarButton}" />
            <loc:ImageButton Command="loc:ResourceBlenderCommands.Delete" Text="Delete" Image="Resources/images/delete_16.png" ShowText="False" ToolTip="Delete Element" Style="{StaticResource ToolBarButton}" />
        </ToolBar>
       
        <Grid DockPanel.Dock="Bottom" Margin="4,0,4,6">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            
            <loc:ImageButton Grid.Column="0" MinWidth="70" Command="ApplicationCommands.Help" Image="Resources/images/question_16.png" ImageLocation="Left" Text="Help"/>
            <loc:ImageButton Grid.Column="2" MinWidth="70" IsDefault="True"  Command="ApplicationCommands.Save" Text="Add" Image="Resources/images/add_16.png" ToolTip="Add Elements" AlwaysShowBorder="True" ImageLocation="Left" HorizontalAlignment="Stretch" />
            <Button Grid.Column="3" MinWidth="70" IsCancel="True" Command="ApplicationCommands.Close">Cancel</Button>
        </Grid>

        <Grid DockPanel.Dock="Bottom" Margin="4,0,4,6">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Label Grid.Row="0" Grid.Column="0">These translations are</Label>
            <ComboBox x:Name="cboLanguage" Grid.Row="0" Grid.Column="1" SelectedValuePath="Key" SelectedValue="{Binding DefaultLanguage}" ItemTemplate="{StaticResource LanguageListItem}" />
            
            <Label Grid.Row="1" Grid.Column="0">Add to bundle</Label>
            <ComboBox x:Name="cboBundle" Grid.Row="1" Grid.Column="1" SelectedValuePath="Key" DisplayMemberPath="Value" ItemsSource="{Binding Bundles}" />
        </Grid>
        
        <dg:DataGrid x:Name="dgResources" DockPanel.Dock="Top" Margin="6" AutoGenerateColumns="False" SelectionMode="Single" SelectionUnit="Cell"
                     EnableRowVirtualization="True" EnableColumnVirtualization="True" HeadersVisibility="Column" RowDetailsVisibilityMode="Collapsed" SelectedValuePath="Translation" IsSynchronizedWithCurrentItem="True"
                     CanUserAddRows="True" CanUserDeleteRows="True" CanUserSortColumns="True" CanUserReorderColumns="False" RowEditEnding="dgResources_RowEditEnding" Background="WhiteSmoke">
            <dg:DataGrid.Columns>
                <dg:DataGridTemplateColumn x:Name="colTranslation" Header="Translation" SortMemberPath="Translation"  Width="*">
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Translation}" TextTrimming="CharacterEllipsis" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0" />
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                    <dg:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox x:Name="txtTranslation" Text="{Binding Translation,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Initialized="txt_Initialized" />
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellEditingTemplate>
                </dg:DataGridTemplateColumn>
            </dg:DataGrid.Columns>
        </dg:DataGrid>
    </DockPanel>
</Window>
